#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main()
{
	uint8_t i[8];
	char port[32] = "/dev/ldusb0";
	
	FILE *fp;
	
	fp = fopen(port,"rb");
	
	if(fp==NULL){
		printf("failed to open %s\n",port);
		exit(-1);
	}
	
	fread(i,sizeof(uint8_t),8,fp);
	
	{
	register int j;
	
	for(j=0;j<8;j++){
		printf("i[%d] = %d\n",j,i[j]);
	}
	}
	
	{
	uint16_t k;
	uint8_t  *m;
	
	m = (uint8_t *)&k;
	
	*m = i[4];
	*(m+1) = i[3];
	
	printf("temp = %.1f *C\n",(double)k/128);
	printf("temp = %.1f *F\n",(double)k/128*9/5+32);
	}
	
	
	return(0);
}
